package tump.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @Description: 测试用例
 */

public class DynamicProxyExample {
    public static void main(String[] args) {
        CalculatorProtocol server = new Server();
        InvocationHandler handler = new CalculatorHandler(server);
        CalculatorProtocol client = (CalculatorProtocol) Proxy.newProxyInstance(server.getClass().getClassLoader(),server.getClass().getInterfaces(),handler);
        int res = client.add(5,3);
        System.out.println(res);

    }
}
